React newsletter


Posted by mijouhsieh on 2023-12-24

codesandbox
練習來源: https://rudy.capital/en/home/#faq
react-form-rudy-newsletter.png

應用 useState, useRef, forwardRef
React useRef

子元件 使用 forwardRef,可讓父元件獲得 子元件的 ref,讓父元件能訪問和操作子元件。

將元件都寫在Form.js中。import forward函式

import React, { useState, forwardRef } from "react";
import { useRef } from "react";
import styles from "./Form.module.css";

子元件

react-form-inputName.png

react-form-inputEmail.png

父元件

react-form.png


再實作相關功能

CHATGTP


#useRef #forwardRef #useState #Reacr form #newsletter







Related Posts

學習 Git (4) - 淺談 Commit 規範

學習 Git (4) - 淺談 Commit 規範

只是看看 JSON 檔案格式

只是看看 JSON 檔案格式

AI輔導室|拒絕再畫傻瓜雙框線

AI輔導室|拒絕再畫傻瓜雙框線


Comments